package cn.wangdazhuang.swing;

import cn.wangdazhuang.StarDictSearcher;

public class Text {

    private int x;
    private int y;
    private int width;
    private int height;

    private String text;
    private boolean visible;

    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public Text(String text) {
        this.text = text;
    }

    public void setBounds(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public String getText() {
        return text;
    }

    public String getTranslation() {
        if (text != null) {
            StarDictSearcher searcher = new StarDictSearcher();
            String translation = searcher.lookup(text.toLowerCase());
            return "<html><body><p>" + text + "<p>&nbsp;&nbsp;&nbsp;&nbsp;" + translation + "</body></html>";
        } else {
            return null;
        }
    }
}
